package cn.credit.loan.service.check;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.credit.loan.dao.check.CheckMapper;
import cn.credit.loan.entity.Check;

@Service
@Transactional
public class CheckServiceImpl implements CheckService {
	@Autowired
	public CheckMapper checkMapper;
	
	Map<String, Object> session=new HashMap<String,Object>();
	/**
	 * 审查专员登录
	 */
	@Override
	public Check checklogin(String checkName, String checkPwd) {
		if(checkName.trim()!=null && checkPwd.trim()!=null) {
			Check check=checkMapper.checklogin(checkName, checkPwd);
			if(check!=null){
				if(!check.getCheckPwd().equals(checkPwd)){
					session.put("error", "用户名不存在");
					return null; 
				}else if(!check.getCheckPwd().equals(checkPwd)){
					session.put("error", "密码输入不正确");
					return null; 
				}
				return check;
			}
			
		}
		return null;
	}
	/**
	 * 审查专员查询
	 */
	@Override
	public List<Check> getCheckList(Check check) throws Exception {
		List<Check> checks=checkMapper.getCheckList(check);
		if(checks!=null)
		{
			return checks;
		}
		return null;
	}
	/**
	 * 审查专员添加
	 */
	@Override
	public boolean getCheckAdd(Check check) throws Exception {
		if(check!=null)
		{
			int num=checkMapper.getCheckAdd(check);
			if(num>0){
				return true;
			}
		}
		return false;
	}
	/**
	 * 审查专员更新
	 */
	@Override
	public boolean getCheckUpdate(Check check) throws Exception {
		if(check!=null)
		{
			int num=checkMapper.getCheckUpdate(check);
			if(num>0){
				return true;
			}
		}
		return false;
	}
	/**
	 * 审查专员删除
	 */
	@Override
	public boolean getCheckDelete(int checkId) throws Exception {
		return checkMapper.getCheckDelete(checkId);
	}

}
